package io.renren.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.renren.common.entity.XlsUpgradeAccountEntity;
import io.renren.common.service.impl.CrudServiceImpl;
import io.renren.dao.XlsUpgradeAccountDao;
import io.renren.dto.XlsUpgradeAccountDTO;
import io.renren.service.XlsUpgradeAccountService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * 用户升级账户表
 *
 * @author Mark sunlightcs@gmail.com
 * @since 1.0.0 2020-04-12
 */
@Service
public class XlsUpgradeAccountServiceImpl extends CrudServiceImpl<XlsUpgradeAccountDao, XlsUpgradeAccountEntity, XlsUpgradeAccountDTO> implements XlsUpgradeAccountService {

    @Autowired
    private XlsUpgradeAccountDao xlsUpgradeAccountDao;

    @Override
    public QueryWrapper<XlsUpgradeAccountEntity> getWrapper(Map<String, Object> params){
        String id = (String)params.get("id");

        QueryWrapper<XlsUpgradeAccountEntity> wrapper = new QueryWrapper<>();
        wrapper.eq(StringUtils.isNotBlank(id), "id", id);

        return wrapper;
    }


    @Override
    public int updateUpgradeAccountByUserId(XlsUpgradeAccountEntity upgradeAccount) {

        return xlsUpgradeAccountDao.updateUpgradeAccountByUserId(upgradeAccount);
    }

    @Override
    public XlsUpgradeAccountEntity selectByUserId(Long userId) {

        return xlsUpgradeAccountDao.selectByUserId(userId);
    }
}